﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for RW_FileCounter
/// </summary>
public class RW_FileCounter
{
	public RW_FileCounter()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static int ReadFile()
    {

        string fileName = HttpContext.Current.Server.MapPath("~/Counter.txt");

        StreamReader objStreamReader;

        objStreamReader = File.OpenText(fileName);

        string sCounter = objStreamReader.ReadToEnd();

        int iCounter = int.Parse(sCounter.ToString());



        objStreamReader.Close();

        return iCounter;

    }

    public static void WriteFile(int iCounter)
    {

        string fileName = HttpContext.Current.Server.MapPath("~/Counter.txt");

        StreamWriter objStreamWrite;

        objStreamWrite = File.CreateText(fileName);

        objStreamWrite.Write(iCounter.ToString());

        objStreamWrite.Close();

    }
}